ajJSONKeyGeneration function
Available since AlchemyJ v5.0
Description
For a structurally complex JSON,such as contain parent-child relationship, after transfer it to table, it is hard to switch back to the original JSON structure. The ajJSONKeyGeneration function help it easy to switch back to the original JSON.
Syntax
ajJSONKeyGeneration(json_data,[run_condition],[run_by_function_point_only])
Argument Name | Argument Type | Description |
---|---|---|
json_data (required) | Range | Specify content of the JSON string from a range of cells. JSON string can span multiple rows and columns, and the content in cells are concatenated into one string from left to right and top to bottom. |
run_condition (optional) | Boolean | The function will run when the value is TRUE. Otherwise will not run. The default value is TRUE. |
run_by_function_point_only (optional) | Boolean | If it equals FALSE, the function can be executed through ‘Excel Calculation’ (can be either Automatic or Manual, Calculate Now or Calculate Sheet) or Preview Function Point. If it equals TRUE, the function can be executed with Preview Function Point (AlchemyJ ribbon \ Preview Function Point) only. The default value is TRUE. |
The function will return:
1) Return Value: JSON String
2) Return Type: Single Value / Multiple values (array formula)
Example
For below JSON, after transfer the JSON to table it hard to switch back the table data to the original JSON string, the ajJSONKeyGeneration function will add the level keys into the JSON to make it easy to switch the table data to the original JSON format. all nodes and data will not change, there will only be a few more level keys in the JSON string.
- Make sure the AlchemyJ Function Proxy was started up when executing ajJSONKeyGeneration in the AlchemyJ workbook. You can start the proxy from More Tools - Run AlchemyJ Function Proxy.
- Generate key for every JSON level use ajJSONKeyGeneration function.
The JSON in the Result as below. It had the level keys generated in the JSON.
After put the JSON data to table can use Data Relationship Schema function make the table data to JSON string. the JSON format and data is same as the original JSON.
The JSON basically same as the original one, there only be a few more level keyss in the JSON string.
Note: If the JSON string already have the JSON level key, it will not re-generate the JSON level key when use this function.
Error Scenarios
It will return #VALUE! when missing any required parameter or mismatch parameter type. Besides, system will raise error for below scenario(s).
Error Scenario |
---|
The format of JSON string is incorrect. |
The JSON string is empty. |